package servlet;

import java.io.IOException;
import java.io.PrintWriter;

import includes.*;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 * Servlet implementation class Help
 */
public class Help extends HttpServlet {
	private static final long serialVersionUID = 1L;
    private Html htmlInclude = new Html();
    /**
     * @see HttpServlet#HttpServlet()
     */
    public Help() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		PrintWriter out = response.getWriter();
		RequestDispatcher rd = request.getRequestDispatcher ("main_links.jsp"); 
		HttpSession currentSession = request.getSession();
		
		out.println(htmlInclude.setHeader("Help"));
		out.println("<div id ='header'></div>");
		out.println("<div id='nav-container'>");
		out.println("<div id='top-links'>");
	    rd.include (request, response);
	    
	    out.println("<div id='login'>");
	    String myname =  (String)currentSession.getAttribute("username");

	    if(myname!=null)
	    {
	    	out.println("<p class='blue'>[ You're logged in as " + myname + " - <a href='Logout'>logout?</a> ]</p>");
	    }
	    else
	    {
	    	out.println("<p class='blue'>[ You're not logged in ]</p>");
	    }
	    out.println("</div>");
	    
	    out.println("</div></div><div id ='content'>");
	    out.println("<div id='content-left'>");
	    out.println("<h3>Author: Thomas Slott, Version: 01</h3>");
	    out.println("</div></div>");
		out.println(htmlInclude.setFooter());
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

}
